/*  This file is part of RsoTool.

    RsoTool is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    RsoTool is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with RsoTool.  If not, see <http://www.gnu.org/licenses/>.
 */
package UI;

import old.*;
import java.io.*;

/**
 *
 * @author spln
 */
public class GUI extends javax.swing.JFrame {

    /**
     * Creates new form GUI
     */
    public GUI() {
        initComponents();
        
        this.isLoaded   = false;
        this.isRso      = false;
        this.rsoFile    = null;
        this.rsoOffset  = 0;
        this.eUI        = new easyUI();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPaneMain = new javax.swing.JTabbedPane();
        jPanelHeader = new javax.swing.JPanel();
        jButtonHeaderImport = new javax.swing.JButton();
        jButtonHeaderExport = new javax.swing.JButton();
        jButtonHeaderExtract = new javax.swing.JButton();
        jButtonHeaderReplace = new javax.swing.JButton();
        jSeparatorHeader = new javax.swing.JSeparator();
        jLabelHeader = new javax.swing.JLabel();
        jPanelData = new javax.swing.JPanel();
        jButtonDataExtract = new javax.swing.JButton();
        jButtonDataExtractAll = new javax.swing.JButton();
        jButtonDataReplace = new javax.swing.JButton();
        jSeparatorData = new javax.swing.JSeparator();
        jTabbedPaneDataBlocks = new javax.swing.JTabbedPane();
        jPanelData01 = new javax.swing.JPanel();
        jLabelData01 = new javax.swing.JLabel();
        jPanelData02 = new javax.swing.JPanel();
        jLabelData02 = new javax.swing.JLabel();
        jPanelData03 = new javax.swing.JPanel();
        jLabelData03 = new javax.swing.JLabel();
        jPanelData04 = new javax.swing.JPanel();
        jLabelData04 = new javax.swing.JLabel();
        jPanelData05 = new javax.swing.JPanel();
        jLabelData05 = new javax.swing.JLabel();
        jPanelData06 = new javax.swing.JPanel();
        jLabelData06 = new javax.swing.JLabel();
        jPanelRelocationTable = new javax.swing.JPanel();
        jButtonRTExport = new javax.swing.JButton();
        jButtonRTExportAll = new javax.swing.JButton();
        jTabbedPaneRelocationTable = new javax.swing.JTabbedPane();
        jScrollPaneIrt = new javax.swing.JScrollPane();
        jTableIrt = new javax.swing.JTable();
        jScrollPaneErt = new javax.swing.JScrollPane();
        jTableErt = new javax.swing.JTable();
        jSeparatorRTE = new javax.swing.JSeparator();
        jPanelFunctions = new javax.swing.JPanel();
        jButtonFunctionsExport = new javax.swing.JButton();
        jButtonFunctionsExportAll = new javax.swing.JButton();
        jTabbedPaneFunctions = new javax.swing.JTabbedPane();
        jScrollPaneExports = new javax.swing.JScrollPane();
        jTableExports = new javax.swing.JTable();
        jScrollPaneImports = new javax.swing.JScrollPane();
        jTableImports = new javax.swing.JTable();
        jSeparatorFunctions = new javax.swing.JSeparator();
        jMenuBarMain = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuFileNew = new javax.swing.JMenu();
        jMenuItemFileNewREL = new javax.swing.JMenuItem();
        jMenuItemFileNewRSO = new javax.swing.JMenuItem();
        jMenuItemFileNewSEL = new javax.swing.JMenuItem();
        jMenuItemFileOpen = new javax.swing.JMenuItem();
        jMenuItemFileOpenAs = new javax.swing.JMenuItem();
        jSeparatorFile1 = new javax.swing.JPopupMenu.Separator();
        jMenuItemDump = new javax.swing.JMenuItem();
        jMenuItemFileSave = new javax.swing.JMenuItem();
        jMenuItemFileSaveAs = new javax.swing.JMenuItem();
        jSeparatorFile2 = new javax.swing.JPopupMenu.Separator();
        jMenuItemFileExtract = new javax.swing.JMenuItem();
        jMenuItemFileExtractAll = new javax.swing.JMenuItem();
        jSeparatorFile3 = new javax.swing.JPopupMenu.Separator();
        jMenuItemFileExit = new javax.swing.JMenuItem();
        jMenuQ = new javax.swing.JMenu();
        jMenuItemQHelp = new javax.swing.JMenuItem();
        jMenuItemQAbout = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("RsoEditor v0.3");

        jButtonHeaderImport.setText("Import");
        jButtonHeaderImport.setEnabled(false);
        jButtonHeaderImport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHeaderImportActionPerformed(evt);
            }
        });

        jButtonHeaderExport.setText("Export");
        jButtonHeaderExport.setEnabled(false);
        jButtonHeaderExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHeaderExportActionPerformed(evt);
            }
        });

        jButtonHeaderExtract.setText("Extract");
        jButtonHeaderExtract.setEnabled(false);
        jButtonHeaderExtract.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHeaderExtractActionPerformed(evt);
            }
        });

        jButtonHeaderReplace.setText("Replace");
        jButtonHeaderReplace.setEnabled(false);
        jButtonHeaderReplace.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHeaderReplaceActionPerformed(evt);
            }
        });

        jLabelHeader.setText("No file loaded.");

        javax.swing.GroupLayout jPanelHeaderLayout = new javax.swing.GroupLayout(jPanelHeader);
        jPanelHeader.setLayout(jPanelHeaderLayout);
        jPanelHeaderLayout.setHorizontalGroup(
            jPanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparatorHeader)
            .addGroup(jPanelHeaderLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanelHeaderLayout.createSequentialGroup()
                        .addComponent(jButtonHeaderImport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonHeaderExport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonHeaderExtract)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonHeaderReplace)
                        .addGap(0, 17, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelHeaderLayout.setVerticalGroup(
            jPanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelHeaderLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonHeaderImport)
                    .addComponent(jButtonHeaderExport)
                    .addComponent(jButtonHeaderExtract)
                    .addComponent(jButtonHeaderReplace))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparatorHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelHeader)
                .addContainerGap(213, Short.MAX_VALUE))
        );

        jTabbedPaneMain.addTab("Header", jPanelHeader);

        jButtonDataExtract.setText("Extract");
        jButtonDataExtract.setEnabled(false);
        jButtonDataExtract.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDataExtractActionPerformed(evt);
            }
        });

        jButtonDataExtractAll.setText("Extract All");
        jButtonDataExtractAll.setEnabled(false);
        jButtonDataExtractAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDataExtractAllActionPerformed(evt);
            }
        });

        jButtonDataReplace.setText("Replace");
        jButtonDataReplace.setEnabled(false);
        jButtonDataReplace.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDataReplaceActionPerformed(evt);
            }
        });

        jLabelData01.setText("No data.");

        javax.swing.GroupLayout jPanelData01Layout = new javax.swing.GroupLayout(jPanelData01);
        jPanelData01.setLayout(jPanelData01Layout);
        jPanelData01Layout.setHorizontalGroup(
            jPanelData01Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData01Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData01)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData01Layout.setVerticalGroup(
            jPanelData01Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData01Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData01)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #1", jPanelData01);

        jLabelData02.setText("No data.");

        javax.swing.GroupLayout jPanelData02Layout = new javax.swing.GroupLayout(jPanelData02);
        jPanelData02.setLayout(jPanelData02Layout);
        jPanelData02Layout.setHorizontalGroup(
            jPanelData02Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData02Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData02)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData02Layout.setVerticalGroup(
            jPanelData02Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData02Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData02)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #2", jPanelData02);

        jLabelData03.setText("No data.");

        javax.swing.GroupLayout jPanelData03Layout = new javax.swing.GroupLayout(jPanelData03);
        jPanelData03.setLayout(jPanelData03Layout);
        jPanelData03Layout.setHorizontalGroup(
            jPanelData03Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData03Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData03)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData03Layout.setVerticalGroup(
            jPanelData03Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData03Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData03)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #3", jPanelData03);

        jLabelData04.setText("No data.");

        javax.swing.GroupLayout jPanelData04Layout = new javax.swing.GroupLayout(jPanelData04);
        jPanelData04.setLayout(jPanelData04Layout);
        jPanelData04Layout.setHorizontalGroup(
            jPanelData04Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData04Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData04)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData04Layout.setVerticalGroup(
            jPanelData04Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData04Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData04)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #4", jPanelData04);

        jLabelData05.setText("No data.");

        javax.swing.GroupLayout jPanelData05Layout = new javax.swing.GroupLayout(jPanelData05);
        jPanelData05.setLayout(jPanelData05Layout);
        jPanelData05Layout.setHorizontalGroup(
            jPanelData05Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData05Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData05)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData05Layout.setVerticalGroup(
            jPanelData05Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData05Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData05)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #5", jPanelData05);

        jLabelData06.setText("No data.");

        javax.swing.GroupLayout jPanelData06Layout = new javax.swing.GroupLayout(jPanelData06);
        jPanelData06.setLayout(jPanelData06Layout);
        jPanelData06Layout.setHorizontalGroup(
            jPanelData06Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData06Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData06)
                .addContainerGap(207, Short.MAX_VALUE))
        );
        jPanelData06Layout.setVerticalGroup(
            jPanelData06Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelData06Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelData06)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        jTabbedPaneDataBlocks.addTab("Block #6", jPanelData06);

        javax.swing.GroupLayout jPanelDataLayout = new javax.swing.GroupLayout(jPanelData);
        jPanelData.setLayout(jPanelDataLayout);
        jPanelDataLayout.setHorizontalGroup(
            jPanelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparatorData)
            .addGroup(jPanelDataLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPaneDataBlocks)
                    .addGroup(jPanelDataLayout.createSequentialGroup()
                        .addComponent(jButtonDataExtract)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonDataExtractAll)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonDataReplace)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelDataLayout.setVerticalGroup(
            jPanelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDataLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonDataExtract)
                    .addComponent(jButtonDataExtractAll)
                    .addComponent(jButtonDataReplace))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparatorData, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPaneDataBlocks)
                .addContainerGap())
        );

        jTabbedPaneMain.addTab("Data", jPanelData);

        jButtonRTExport.setText("Export");
        jButtonRTExport.setEnabled(false);
        jButtonRTExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRTExportActionPerformed(evt);
            }
        });

        jButtonRTExportAll.setText("Export all");
        jButtonRTExportAll.setEnabled(false);
        jButtonRTExportAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRTExportAllActionPerformed(evt);
            }
        });

        jTableIrt.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "r_offset", "r_info", "r_addend"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPaneIrt.setViewportView(jTableIrt);

        jTabbedPaneRelocationTable.addTab("Internal", jScrollPaneIrt);

        jTableErt.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "r_offset", "r_info", "r_addend"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPaneErt.setViewportView(jTableErt);

        jTabbedPaneRelocationTable.addTab("External", jScrollPaneErt);

        javax.swing.GroupLayout jPanelRelocationTableLayout = new javax.swing.GroupLayout(jPanelRelocationTable);
        jPanelRelocationTable.setLayout(jPanelRelocationTableLayout);
        jPanelRelocationTableLayout.setHorizontalGroup(
            jPanelRelocationTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRelocationTableLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelRelocationTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPaneRelocationTable, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanelRelocationTableLayout.createSequentialGroup()
                        .addComponent(jButtonRTExport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonRTExportAll)
                        .addGap(0, 142, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jSeparatorRTE)
        );
        jPanelRelocationTableLayout.setVerticalGroup(
            jPanelRelocationTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRelocationTableLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelRelocationTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonRTExport)
                    .addComponent(jButtonRTExportAll))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparatorRTE, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPaneRelocationTable, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPaneMain.addTab("Relocation Table", jPanelRelocationTable);

        jButtonFunctionsExport.setText("Export");
        jButtonFunctionsExport.setEnabled(false);
        jButtonFunctionsExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFunctionsExportActionPerformed(evt);
            }
        });

        jButtonFunctionsExportAll.setText("Export all");
        jButtonFunctionsExportAll.setEnabled(false);
        jButtonFunctionsExportAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFunctionsExportAllActionPerformed(evt);
            }
        });

        jTableExports.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "id", "section", "offset", "name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPaneExports.setViewportView(jTableExports);

        jTabbedPaneFunctions.addTab("Exports", jScrollPaneExports);

        jTableImports.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "id", "section", "offset", "name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPaneImports.setViewportView(jTableImports);

        jTabbedPaneFunctions.addTab("Imports", jScrollPaneImports);

        javax.swing.GroupLayout jPanelFunctionsLayout = new javax.swing.GroupLayout(jPanelFunctions);
        jPanelFunctions.setLayout(jPanelFunctionsLayout);
        jPanelFunctionsLayout.setHorizontalGroup(
            jPanelFunctionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFunctionsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFunctionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPaneFunctions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanelFunctionsLayout.createSequentialGroup()
                        .addComponent(jButtonFunctionsExport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonFunctionsExportAll)
                        .addGap(0, 142, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jSeparatorFunctions)
        );
        jPanelFunctionsLayout.setVerticalGroup(
            jPanelFunctionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFunctionsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFunctionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonFunctionsExport)
                    .addComponent(jButtonFunctionsExportAll))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparatorFunctions, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPaneFunctions, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPaneMain.addTab("Functions", jPanelFunctions);

        jMenuFile.setText("File");

        jMenuFileNew.setText("New");
        jMenuFileNew.setEnabled(false);

        jMenuItemFileNewREL.setText("REL file");
        jMenuItemFileNewREL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileNewRELActionPerformed(evt);
            }
        });
        jMenuFileNew.add(jMenuItemFileNewREL);

        jMenuItemFileNewRSO.setText("RSO file");
        jMenuItemFileNewRSO.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileNewRSOActionPerformed(evt);
            }
        });
        jMenuFileNew.add(jMenuItemFileNewRSO);

        jMenuItemFileNewSEL.setText("SEL file");
        jMenuItemFileNewSEL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileNewSELActionPerformed(evt);
            }
        });
        jMenuFileNew.add(jMenuItemFileNewSEL);

        jMenuFile.add(jMenuFileNew);

        jMenuItemFileOpen.setText("Open");
        jMenuItemFileOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileOpenActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileOpen);

        jMenuItemFileOpenAs.setText("Open as...");
        jMenuItemFileOpenAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileOpenAsActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileOpenAs);
        jMenuFile.add(jSeparatorFile1);

        jMenuItemDump.setText("Dump");
        jMenuItemDump.setEnabled(false);
        jMenuItemDump.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDumpActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemDump);

        jMenuItemFileSave.setText("Save");
        jMenuItemFileSave.setEnabled(false);
        jMenuItemFileSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileSaveActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileSave);

        jMenuItemFileSaveAs.setText("Save as...");
        jMenuItemFileSaveAs.setEnabled(false);
        jMenuItemFileSaveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileSaveAsActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileSaveAs);
        jMenuFile.add(jSeparatorFile2);

        jMenuItemFileExtract.setText("Extract...");
        jMenuItemFileExtract.setEnabled(false);
        jMenuItemFileExtract.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileExtractActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileExtract);

        jMenuItemFileExtractAll.setText("Extract all");
        jMenuItemFileExtractAll.setEnabled(false);
        jMenuItemFileExtractAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileExtractAllActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileExtractAll);
        jMenuFile.add(jSeparatorFile3);

        jMenuItemFileExit.setText("Exit");
        jMenuItemFileExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFileExitActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemFileExit);

        jMenuBarMain.add(jMenuFile);

        jMenuQ.setText("?");

        jMenuItemQHelp.setText("Help");
        jMenuItemQHelp.setEnabled(false);
        jMenuItemQHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemQHelpActionPerformed(evt);
            }
        });
        jMenuQ.add(jMenuItemQHelp);

        jMenuItemQAbout.setText("About");
        jMenuItemQAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemQAboutActionPerformed(evt);
            }
        });
        jMenuQ.add(jMenuItemQAbout);

        jMenuBarMain.add(jMenuQ);

        setJMenuBar(jMenuBarMain);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPaneMain)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPaneMain, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    //--- Buttons Events
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] Header              - Buttons Event">
    private void jButtonHeaderImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHeaderImportActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonHeaderImportActionPerformed

    private void jButtonHeaderExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHeaderExportActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonHeaderExportActionPerformed

    private void jButtonHeaderExtractActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHeaderExtractActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonHeaderExtractActionPerformed

    private void jButtonHeaderReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHeaderReplaceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonHeaderReplaceActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] Data                - Buttons Event">
    private void jButtonDataExtractActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDataExtractActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Binary file"}, new String[] {".bin"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Extract Data Block
        java.awt.Component tab = jTabbedPaneDataBlocks.getSelectedComponent();
        try {
            if (tab == jPanelData01) {
                rsoFile.extractDataBlock(rsoFile.block01Offset, rsoFile.block01Size, out);
            } else if (tab == jPanelData02) {
                rsoFile.extractDataBlock(rsoFile.block02Offset, rsoFile.block02Size, out);
            } else if (tab == jPanelData03) {
                rsoFile.extractDataBlock(rsoFile.block03Offset, rsoFile.block03Size, out);
            } else if (tab == jPanelData04) {
                rsoFile.extractDataBlock(rsoFile.block04Offset, rsoFile.block04Size, out);
            } else if (tab == jPanelData05) {
                rsoFile.extractDataBlock(rsoFile.block05Offset, rsoFile.block05Size, out);
            } else if (tab == jPanelData06) {
                rsoFile.extractDataBlock(rsoFile.block06Offset, rsoFile.block06Size, out);
            } 
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Data block extracted!", "Done", easyUI.MBIcon_INFORMATION);
        
    }//GEN-LAST:event_jButtonDataExtractActionPerformed

    private void jButtonDataExtractAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDataExtractAllActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        File dir = eUI.getDirectory();
        if (dir == null || !dir.isDirectory()) {
            eUI.messageBoxExt(this, "Isn't a directory!", "Failed to save files", easyUI.MBIcon_ERROR);
            return;
        }
        
        try {
            rsoFile.extractAllDataBlock(dir);
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Data blocks extracted!", "Done", easyUI.MBIcon_INFORMATION); 
    }//GEN-LAST:event_jButtonDataExtractAllActionPerformed

    private void jButtonDataReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDataReplaceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonDataReplaceActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] Relocation Table    - Buttons Event">
    private void jButtonRTExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRTExportActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Text file"}, new String[] {".txt"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Export
        java.awt.Component comp = jTabbedPaneRelocationTable.getSelectedComponent();
        try {
            if (comp == jScrollPaneErt) {
                rsoFile.exportRelocationTable(ert, out);
            } else if (comp == jScrollPaneIrt) {
                rsoFile.exportRelocationTable(irt, out);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Relocation table exported!", "Done", easyUI.MBIcon_INFORMATION);
    }//GEN-LAST:event_jButtonRTExportActionPerformed

    private void jButtonRTExportAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRTExportAllActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Text file"}, new String[] {".txt"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Export All
        try {
            rsoFile.exportAllRelocationTable(irt, ert, out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Relocation tables exported!", "Done", easyUI.MBIcon_INFORMATION);
    }//GEN-LAST:event_jButtonRTExportAllActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] Functions           - Buttons Event">
    private void jButtonFunctionsExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFunctionsExportActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Text file"}, new String[] {".txt"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Export
        java.awt.Component comp = jTabbedPaneFunctions.getSelectedComponent();
        try {
            if (comp == jScrollPaneExports) {
                rsoFile.exportExports(exp, out);
            } else if (comp == jScrollPaneImports) {
                rsoFile.exportImports(imp, out);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Imports/Exports exported!", "Done", easyUI.MBIcon_INFORMATION);
    }//GEN-LAST:event_jButtonFunctionsExportActionPerformed

    private void jButtonFunctionsExportAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFunctionsExportAllActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Text file"}, new String[] {".txt"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Export All
        try {
            rsoFile.exportAllFunctions(exp, imp, out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Imports and Exports exported!", "Done", easyUI.MBIcon_INFORMATION);
    }//GEN-LAST:event_jButtonFunctionsExportAllActionPerformed
    
    //</editor-fold>
    
    
    //--- Menu Events
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] File > New          - Items Event">
    private void jMenuItemFileNewRELActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileNewRELActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileNewRELActionPerformed

    private void jMenuItemFileNewRSOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileNewRSOActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileNewRSOActionPerformed

    private void jMenuItemFileNewSELActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileNewSELActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileNewSELActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] File > Open         - Items Event">
    private void jMenuItemFileOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileOpenActionPerformed
        // TODO add your handling code here:
        String[] desc = new String[] {"RSO files"};
        String[] filter = new String[] {".rso"};
        File f = eUI.getOpenFilename(desc, filter);
        if (f == null || !f.exists()) { 
            eUI.messageBoxExt(this, "File doesn't exist!", "Failed to open file", easyUI.MBIcon_ERROR);
            return;
        } 
        
        //--- Loading RSO file
        rsoFile = new RSO(f);
        if (!rsoFile.exists()) {
            eUI.messageBoxExt(this, "RSO file doesn't exist!", "Failed to open file", easyUI.MBIcon_ERROR);
            return;
        }
        
        rsoFile.load(rsoOffset);
        String err = rsoFile.check();
        if (!err.equals("")) {
            eUI.messageBoxExt(this, "<html>"+err+"</html>", "RSO File check", easyUI.MBIcon_WARNING);
            jLabelHeader.setText(String.format("<html>File loaded with error/warning(s):<br />"+err+"</html>"));
        } else {
            jLabelHeader.setText(String.format("File loaded successfuly!"));
        } 
            
        //--- Enable GUI
        isLoaded = true;
        jButtonDataExtract.setEnabled(true);
        jButtonDataExtractAll.setEnabled(true);
        jButtonRTExport.setEnabled(true);
        jButtonRTExportAll.setEnabled(true);
        jButtonFunctionsExport.setEnabled(true);
        jButtonFunctionsExportAll.setEnabled(true);
        jMenuItemDump.setEnabled(true);
        
        //--- Write Block properties
        jLabelData01.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block01Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block01Size)+"</html>");
        jLabelData02.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block02Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block02Size)+"</html>");
        jLabelData03.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block03Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block03Size)+"</html>");
        jLabelData04.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block04Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block04Size)+"</html>");
        jLabelData05.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block05Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block05Size)+"</html>");
        jLabelData06.setText("<html>Offset: 0x"+Long.toHexString(rsoFile.block06Offset)+"<br />"+
                                    "Size:  0x"+Long.toHexString(rsoFile.block06Size)+"</html>");
    
        //--- Write Internal Relocation Table
        javax.swing.table.DefaultTableModel modelIrt = (javax.swing.table.DefaultTableModel) jTableIrt.getModel();
        irt = rsoFile.getRelocationTable(rsoFile.irtOffset, rsoFile.irtSize);
        modelIrt.setRowCount(0); if (irt == null) { return; }
        
        for (int i=0; i < irt[0].length; i++){
            modelIrt.addRow(new String[] { irt[0][i], irt[1][i], irt[2][i] });
        }
        modelIrt.fireTableDataChanged();
        
        //--- Write External Relocation Table properties  
        javax.swing.table.DefaultTableModel modelErt = (javax.swing.table.DefaultTableModel) jTableErt.getModel();
        ert = rsoFile.getRelocationTable(rsoFile.ertOffset, rsoFile.ertSize);
        modelErt.setRowCount(0); if (ert == null) { return; }
        
        for (int i=0; i < ert[0].length; i++){
            modelErt.addRow(new String[] { ert[0][i], ert[1][i], ert[2][i] });
        }
        modelErt.fireTableDataChanged();
        
        //--- Write Imports
        javax.swing.table.DefaultTableModel modelImp = (javax.swing.table.DefaultTableModel) jTableImports.getModel();
        imp = rsoFile.getImports(rsoFile.importsOffset, rsoFile.importsSize);
        modelImp.setRowCount(0); if (imp == null) { return; }
        
        for (int i=0; i < imp[0].length; i++){
            modelImp.addRow(new String[] { String.format("%08X", i), imp[1][i], imp[2][i], imp[3][i] });
        }
        modelImp.fireTableDataChanged();
        
        //--- Write Exports
        javax.swing.table.DefaultTableModel modelExp = (javax.swing.table.DefaultTableModel) jTableExports.getModel();
        exp = rsoFile.getExports(rsoFile.exportsOffset, rsoFile.exportsSize);
        modelExp.setRowCount(0); if (exp == null) { return; }
        
        for (int i=0; i < exp[0].length; i++){
            modelExp.addRow(new String[] { String.format("%08X", i), exp[2][i], exp[1][i], exp[4][i] });
        }
        modelExp.fireTableDataChanged();
        
    }//GEN-LAST:event_jMenuItemFileOpenActionPerformed

    private void jMenuItemFileOpenAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileOpenAsActionPerformed
        // TODO add your handling code here:
        String nb = eUI.getStringExt(this, "Enter RSO offset:", "Input", easyUI.MBIcon_INFORMATION);
        Long offset;
        
        //--- Get input
        try {
            offset = Long.parseLong(nb);
        } catch (NumberFormatException e){
            eUI.messageBoxExt(this, "Isn't a valide number!", "Input error", easyUI.MBIcon_ERROR);
            e.printStackTrace();
            return;
        }
        
        //--- Open the RSO file
        rsoOffset = offset;
        jMenuItemFileOpenActionPerformed(null);
    }//GEN-LAST:event_jMenuItemFileOpenAsActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] File > Save         - Items Event">
    
    private void jMenuItemDumpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDumpActionPerformed
        // TODO add your handling code here:
        if (!isLoaded) {
            eUI.messageBoxExt(this, "Rso file isn't loaded!", "Failed to load RSO file", easyUI.MBIcon_ERROR);
            return;
        }
        
        //--- Get File
        File out = eUI.getSaveFilename(new String[] {"Text file"}, new String[] {".txt"});
        if (out == null) {
            eUI.messageBoxExt(this, "File error!", "Failed to save file", easyUI.MBIcon_ERROR);
            return;
        } else if (out.exists()) {
            eUI.messageBoxExt(this, "File already exists!", "Failed to save file", easyUI.MBIcon_INFORMATION);
            return;
        }
        
        //--- Dump
        try {
            rsoFile.dump(exp, imp, irt, ert, out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        eUI.messageBoxExt(this, "Data dumped successfuly!", "Done", easyUI.MBIcon_INFORMATION);
    }//GEN-LAST:event_jMenuItemDumpActionPerformed
    
    private void jMenuItemFileSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileSaveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileSaveActionPerformed

    private void jMenuItemFileSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileSaveAsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileSaveAsActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] File > Extract      - Items Event">
    private void jMenuItemFileExtractActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileExtractActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileExtractActionPerformed

    private void jMenuItemFileExtractAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileExtractAllActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileExtractAllActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] File > System       - Items Event">
    private void jMenuItemFileExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFileExitActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemFileExitActionPerformed
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="[GUI] ? > Help/About      - Items Event">
    private void jMenuItemQHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemQHelpActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemQHelpActionPerformed

    private void jMenuItemQAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemQAboutActionPerformed
        // TODO add your handling code here:
        eUI.messageBox(this,String.format(
                            "    RsoTool v0.3 %n %n"+
                            "    Copyright © 2013  SPLN (sepalani) %n"+
                            "    This program is free software: you can redistribute it and/or modify%n" +
                            "    it under the terms of the GNU General Public License as published by%n" +
                            "    the Free Software Foundation, either version 3 of the License, or%n" +
                            "    (at your option) any later version.%n" +
                            "%n" +
                            "    This program is distributed in the hope that it will be useful,%n" +
                            "    but WITHOUT ANY WARRANTY; without even the implied warranty of%n" +
                            "    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%n" +
                            "    GNU General Public License for more details.%n" +
                            "%n" +
                            "    You should have received a copy of the GNU General Public License%n" +
                            "    along with this program.  If not, see <http://www.gnu.org/licenses/>."));
    }//GEN-LAST:event_jMenuItemQAboutActionPerformed
    //</editor-fold>
    
    
      
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        
        /* Custom Code*/
        
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new GUI().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonDataExtract;
    private javax.swing.JButton jButtonDataExtractAll;
    private javax.swing.JButton jButtonDataReplace;
    private javax.swing.JButton jButtonFunctionsExport;
    private javax.swing.JButton jButtonFunctionsExportAll;
    private javax.swing.JButton jButtonHeaderExport;
    private javax.swing.JButton jButtonHeaderExtract;
    private javax.swing.JButton jButtonHeaderImport;
    private javax.swing.JButton jButtonHeaderReplace;
    private javax.swing.JButton jButtonRTExport;
    private javax.swing.JButton jButtonRTExportAll;
    private javax.swing.JLabel jLabelData01;
    private javax.swing.JLabel jLabelData02;
    private javax.swing.JLabel jLabelData03;
    private javax.swing.JLabel jLabelData04;
    private javax.swing.JLabel jLabelData05;
    private javax.swing.JLabel jLabelData06;
    private javax.swing.JLabel jLabelHeader;
    private javax.swing.JMenuBar jMenuBarMain;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenu jMenuFileNew;
    private javax.swing.JMenuItem jMenuItemDump;
    private javax.swing.JMenuItem jMenuItemFileExit;
    private javax.swing.JMenuItem jMenuItemFileExtract;
    private javax.swing.JMenuItem jMenuItemFileExtractAll;
    private javax.swing.JMenuItem jMenuItemFileNewREL;
    private javax.swing.JMenuItem jMenuItemFileNewRSO;
    private javax.swing.JMenuItem jMenuItemFileNewSEL;
    private javax.swing.JMenuItem jMenuItemFileOpen;
    private javax.swing.JMenuItem jMenuItemFileOpenAs;
    private javax.swing.JMenuItem jMenuItemFileSave;
    private javax.swing.JMenuItem jMenuItemFileSaveAs;
    private javax.swing.JMenuItem jMenuItemQAbout;
    private javax.swing.JMenuItem jMenuItemQHelp;
    private javax.swing.JMenu jMenuQ;
    private javax.swing.JPanel jPanelData;
    private javax.swing.JPanel jPanelData01;
    private javax.swing.JPanel jPanelData02;
    private javax.swing.JPanel jPanelData03;
    private javax.swing.JPanel jPanelData04;
    private javax.swing.JPanel jPanelData05;
    private javax.swing.JPanel jPanelData06;
    private javax.swing.JPanel jPanelFunctions;
    private javax.swing.JPanel jPanelHeader;
    private javax.swing.JPanel jPanelRelocationTable;
    private javax.swing.JScrollPane jScrollPaneErt;
    private javax.swing.JScrollPane jScrollPaneExports;
    private javax.swing.JScrollPane jScrollPaneImports;
    private javax.swing.JScrollPane jScrollPaneIrt;
    private javax.swing.JSeparator jSeparatorData;
    private javax.swing.JPopupMenu.Separator jSeparatorFile1;
    private javax.swing.JPopupMenu.Separator jSeparatorFile2;
    private javax.swing.JPopupMenu.Separator jSeparatorFile3;
    private javax.swing.JSeparator jSeparatorFunctions;
    private javax.swing.JSeparator jSeparatorHeader;
    private javax.swing.JSeparator jSeparatorRTE;
    private javax.swing.JTabbedPane jTabbedPaneDataBlocks;
    private javax.swing.JTabbedPane jTabbedPaneFunctions;
    private javax.swing.JTabbedPane jTabbedPaneMain;
    private javax.swing.JTabbedPane jTabbedPaneRelocationTable;
    private javax.swing.JTable jTableErt;
    private javax.swing.JTable jTableExports;
    private javax.swing.JTable jTableImports;
    private javax.swing.JTable jTableIrt;
    // End of variables declaration//GEN-END:variables
    // Variables declaration (Custom)
    easyUI eUI;
    private boolean     isLoaded;           // Is a file loaded
    private boolean     isRso;              // Is an *.rso file
    private RSO         rsoFile;            // Rso file
    private long        rsoOffset;          // Rso offset
    private String[][]  irt, ert, imp, exp; // Relocation Table
}
